package com.zhaoyu.admin.controller;

import com.zhaoyu.admin.service.AdSensitiveService;
import com.zhaoyu.apis.admin.AdSensitiveControllerApis;
import com.zhaoyu.model.admin.dtos.SensitiveDto;
import com.zhaoyu.model.admin.pojos.AdSensitive;
import com.zhaoyu.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController implements AdSensitiveControllerApis {

    @Autowired
    private AdSensitiveService adSensitiveService;

    @Override
    @PostMapping("/list") // json格式的数据
    public ResponseResult findByNameAndPageAdSensitive(@RequestBody SensitiveDto sensitiveDto){
        return adSensitiveService.findByNameAndPage(sensitiveDto);
    }

    @Override
    @PostMapping("/save") // json格式的数据
    public ResponseResult saveAdSensitive(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.insert(adSensitive);
    }

    @Override
    @PostMapping("/update") // json格式的数据
    public ResponseResult updateAdSensitive(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.edit(adSensitive);
    }

    @Override
    @DeleteMapping("/del/{id}") // rest风格
    public ResponseResult deleteByIdAdSensitive(@PathVariable("id") Integer id){
        return adSensitiveService.deleteById(id);
    }

}